//
//  DHNoDataView.m
//  jiaZiShop
//
//  Created by Apple on 2021/5/14.
//

#import "DHNoDataView.h"

@implementation DHNoDataView

-(instancetype)init{
    self = [super init];
    if (self) {
        [self setupUI];
    }
    return self;
}

-(void)setupUI{
    self.backgroundColor = [UIColor clearColor];
    
    [self addSubview:self.noDataImg];
    [self addSubview:self.noDataLabel];
    [self addSubview:self.noDataBtn];
    [self.noDataImg mas_updateConstraints:^(MASConstraintMaker *make) {
        make.width.equalTo(self).dividedBy(2);
        make.height.equalTo(self.noDataImg.mas_width).dividedBy(1);
        make.centerX.equalTo(self);
        make.centerY.equalTo(self).offset(-0);
    }];
//    [self.noDataLabel mas_updateConstraints:^(MASConstraintMaker *make) {
//        make.top.equalTo(self.noDataImg.mas_bottom).offset(15);
//        make.centerX.equalTo(self);
//        make.height.mas_equalTo(40);
//    }];
//    [self.noDataBtn mas_updateConstraints:^(MASConstraintMaker *make) {
//        make.top.equalTo(self.noDataImg.mas_bottom).offset(15);
//        make.centerX.equalTo(self);
//        make.height.mas_equalTo(40);
//    }];
}

//#pragma mark - 无数据展示视图
//- (UIView *)noDataView{
//    if (!_noDataView) {
//        _noDataView = [[UIView alloc] initWithFrame:CGRectZero];
//        _noDataView.backgroundColor = [UIColor whiteColor];
//        _noDataView.hidden = YES;
//        [_noDataView addSubview:self.noDataImg];
//        [_noDataView addSubview:self.noDataLabel];
//        [_noDataView addSubview:self.noDataBtn];
//        [self.noDataImg mas_updateConstraints:^(MASConstraintMaker *make) {
//            make.width.equalTo(155);
//            make.height.equalTo(201);
//            make.centerX.equalTo(self.noDataView);
//            make.centerY.equalTo(self.noDataView).offset(-50);
//        }];
//        [self.noDataLabel mas_updateConstraints:^(MASConstraintMaker *make) {
//            make.top.equalTo(self.noDataImg.bottom).offset(15);
//            make.left.right.equalTo(self.noDataView);
//        }];
//        [self.noDataBtn mas_updateConstraints:^(MASConstraintMaker *make) {
//            make.top.equalTo(self.noDataLabel.bottom).offset(22);
//            make.centerX.equalTo(self.noDataView);
//            make.size.equalTo(CGSizeMake(120, 42));
//        }];
//    }
//    return _noDataView;
//}
- (UIImageView *)noDataImg{
    if (!_noDataImg) {
        _noDataImg = [[UIImageView alloc] init];
        _noDataImg.image = [UIImage imageNamed:@"nodata"];
    }
    return _noDataImg;
}
- (UILabel *)noDataLabel{
    if (!_noDataLabel) {
        _noDataLabel = [[UILabel alloc] init];
        _noDataLabel.text = @" ";
        _noDataLabel.textColor = [UIColor dc_colorWithHexString:@"#959191"];
        _noDataLabel.font = [UIFont systemFontOfSize:14];
        _noDataLabel.textAlignment = NSTextAlignmentCenter;
    }
    return _noDataLabel;
}
- (UIButton *)noDataBtn{
    if (!_noDataBtn) {
        _noDataBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [_noDataBtn setTitle:@"去逛逛" forState:0];
        [_noDataBtn setTitleColor:[UIColor dc_colorWithHexString:@"#959191"] forState:0];
        _noDataBtn.cornerRadius = 20;
        _noDataBtn.titleLabel.font = [UIFont systemFontOfSize:14];
        [_noDataBtn addTarget:self action:@selector(noDataBtnClick) forControlEvents:UIControlEventTouchUpInside];
        _noDataBtn.hidden = YES;
    }
    return _noDataBtn;
}
-(void)noDataBtnClick{
    if (self.btnBlock) {
        self.btnBlock();
    }
}


/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
